package com.xx;

public class Test {
    public static void main(String[] args) {
        Person[] person=new Person[5];
        person[0]=new Person("bob",28);
        person[1]=new Student("jack",18,89.9);
        person[2]=new Student("mark",17,85.5);
        person[3]=new Teacher("hsp",38,10000);
        person[4]=new Teacher("sgg",40,20000);
for(int i=0;i<person.length;i++){
    if(person[i]instanceof Student){
        Student student=(Student) person[i];
        System.out.println("学生\t"+student.say());
    }
    else if(person[i]instanceof Teacher){
        Teacher teacher=(Teacher) person[i];
        System.out.println("老师\t"+teacher.say());
    }
    else if(person[i]instanceof Person){
        System.out.println(person[i].say());
    }
    else{
        System.out.println("类型有误");
    }
    }
}
}
